package com.imooc.ecommerce.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: NacosClientService
 * Package: com.imooc.ecommerce.service
 *
 * @Author 马学兴
 * @Create 2024/3/26 17:05
 * @Version 1.0
 * Description:
 */
@Slf4j
@Service
public class NacosClientService {
    private final DiscoveryClient discoveryClient;

    public NacosClientService(DiscoveryClient discoveryClient) {
        this.discoveryClient = discoveryClient;
    }
    //打印Nacos Client信息到日志中
    public List<ServiceInstance> getNacosClientInfo(String serviceId){
        log.info("request nacos client to get service instance info :[{}]",serviceId);
        return discoveryClient.getInstances(serviceId);

    }
}
